field id 5 of page id 3 ,field id 35 of page id 3,field id 36 of page id 3,field id 37 of page id 3
System
General
"pGenRemarks"
buttonUp
buttonUp
pGenRemarks
Some general remarks about hotwords....
RFields
"pRecordFields"
buttonUp
buttonUp
pRecordFields
Hotwords in Record Fields...
FgFields
"pForegroundFields"
buttonUp
buttonUp
pForegroundFields
Hotwords in Foreground Fields...
The Hotword Book
RFields
"pBackFields"
buttonUp
buttonUp
pBackFields
Hotwords in Background Fields...
pMainMenu
The Hotword Book
pGenRemarks
One of the more useful features of OpenScript is the ability to create objects "on the fly", that is, from scripts as they execute. Among the objects that can be created from a script are hotwords, essential to any serious hypermedia application. Many of our users want to (for example) open a text file, read it into fields, search for certain words or phrases, and create links to other pages. This is complicated by problems in "finding" hotwords immediately after their creation. The purpose of this book is to provide working examples of dynamic creation of hotwords in each of the three types of fields in Toolbook.
In order to understand the care and feeding of hotword objects, we need to understand the nature of their habitat, the Toolbook field. There are three types of Toolbook field: foreground, background, and record fields. Toolbook field objects(taken together) have one great strength and one great weakness. Their strength lies in the fact that the field types have unique features, and can complement their cousins if used right. Their weakness lies in the fact each each field type has unique features, and must be handled in a unique manner.
The principal difference between field types is the location of their text. The text in a background field lives in the background with the field. This is useful for header lines and titles where the text does not change from page to page; for example, the title "The Hotword Book" at the top of this page is in a background field. The text of record fields, on the other hand, lives in the foreground, while the recordfield itself lives on the background. This is useful for preparing blank forms, where the overall format is the same on each page, but the text entered on each page will change.
Problems arise when users look for hotwords in the wrong place. This is compounded by the fact that some hotwords "move" as they are created, so they cannot be found in the same place as their text! This book is organized along the lines of field types -one page, one field type. This is no accident. Each page contains a valid reference to a hotword of that field type.
ick cribsheet, look at the "HotHandle" field on each page.
e you have a handle on the hotwords, you have several tools available for accessing them.
MainMenu
pMainMenu
buttonUp
buttonUp
pMainMenu
Main Menu
fGenRemarks
The Hotword Book
pRecordFields
This is RecordField "RecField1". Although the recordfield is in the background, the text lives in the foreground, and the hotwords are objects of this recordfield of either the page or background.
bCreateHw
fScripts
storage
"RecField1"
buttonUp
buttonUp
RecField1
hotword
GRcreateHotword
RecField1
Create Hotwords
bDestroyHW
RecField1
fScripts
storage
RecordField
Recordfield
buttonUp
buttonUp
hotword
gremoveHotword
hotword
gremoveHotword
storage
fScripts
RecField1
Destroy Hotwords
fScripts
opartner
ocohort
orival
buttonUp
buttonUp
partner
cohort
rival
cohort
button id 34 of page id 3
partner
button id 33 of page id 3
rival
field id 37 of page id 3
to handle buttonUp
set syslockscreen to true
--put text of field fScripts into storage
--set text of field fScripts to null
search page records for "RecField1"
if selection contains "hotword"
set name of selection to selectedText
break to system
end
send createHotword
get objects of recordField RecField1 of this page
set name of last item of it to selectedText
set activated of recordField RecField1 to true
--put storage into text of field fScripts
Scripts
opartner
BbCreateHW
orival
ocohort
buttonUp
buttonUp
partner
partner
rival
cohort
bCreateHW
partner
field id 5 of page id 3
rival
field id 37 of page id 3
cohort
button id 34 of page id 3
Scripts
remarks
opartner
orival
ocohort
buttonUp
buttonUp
partner
rival
cohort
cohort
button id 33 of page id 3
partner
field id 37 of page id 3
rival
field id 5 of page id 3
Remarks
fScripts
opartner
orival
buttonUp
buttonUp
partner
rival
partner
button id 3 of page id 2
rival
field id 31 of page id 2
to handle buttonUp
set syslockscreen to true
put text of field fScripts into storage
set text of field fScripts to null
search page for "ForeField1"
if selection contains "hotword"
set name of selection to selectedText
break to system
end
send createHotword
get objects of field ForeField1 of this page
set name of last item of it to selectedText
set activated of field ForeField1 to true
put storage into text of field fScripts
remarks
opartner
ocohort
orival
buttonUp
buttonUp
partner
cohort
rival
cohort
button id 33 of page id 3
rival
field id 5 of page id 3
partner
button id 34 of page id 3
This is the text
MainMenu
pMainMenu
buttonUp
buttonUp
pMainMenu
Main Menu
MainMenu
pMainMenu
buttonUp
buttonUp
pMainMenu
Main Menu
The Hotword Book
RecField1
pRecordFields
This is RecordField "RecField1". Although the recordfield is in the background, the text lives in the foreground, and the hotwords are objects of this recordfield of either the page or background.
bCreateHw
cField1
Create Hotwords
bDestroyHW
RecField1
fScripts
storage
RecordField
Recordfield
buttonUp
buttonUp
hotword
gremoveHotword
hotword
gremoveHotword
storage
fScripts
RecField1
Destroy Hotwords
fScripts
opartner
ocohort
orival
buttonUp
buttonUp
partner
cohort
rival
cohort
button id 34 of page id 3
partner
button id 33 of page id 3
rival
field id 37 of page id 3
--Hide the gory details
--Search
"RecField1"
--Is
already a
--If so, quit early
--If you got
far, there
--so create one
--Get a
. See "remarks"
--Activate
scripts so
works OK
buttonUp
buttonUp
RecField1
hotword
GRcreateHotword
RecField1
fScripts
Scripts
opartner
BbCreateHW
orival
ocohort
buttonUp
buttonUp
partner
partner
rival
cohort
bCreateHW
partner
field id 5 of page id 3
rival
field id 37 of page id 3
cohort
button id 34 of page id 3
Scripts
remarks
opartner
orival
ocohort
buttonUp
buttonUp
partner
rival
cohort
cohort
button id 33 of page id 3
partner
field id 37 of page id 3
rival
field id 5 of page id 3
Remarks
fScripts
opartner
orival
buttonUp
buttonUp
partner
rival
partner
button id 3 of page id 2
rival
field id 31 of page id 2
to handle buttonUp
set syslockscreen to true
put text of field fScripts into storage
set text of field fScripts to null
search page for "ForeField1"
if selection contains "hotword"
set name of selection to selectedText
break to system
end
send createHotword
get objects of field ForeField1 of this page
set name of last item of it to selectedText
set activated of field ForeField1 to true
put storage into text of field fScripts
remarks
opartner
ocohort
orival
buttonUp
buttonUp
partner
cohort
rival
cohort
button id 33 of page id 3
rival
field id 5 of page id 3
partner
button id 34 of page id 3
The text of record fields, lik
MainMenu
pMainMenu
buttonUp
buttonUp
pMainMenu
Main Menu
to handle buttonUp
--Hide the gory details from the user
set syslockscreen to true
--Search for the text string, select it
search page records for "RecField1"
--Is it already a hotword?
--If so, quit early
if selection contains "hotword"
break to system
end
--If you got this far, there is no hotword,
--so create one
send createHotword
--Get a handle of the hotword. See "remarks" field!
get objects of recordField RecField1 of this page
set name of last item of it to selectedText
--Activate the scripts so it works OK
set activated of recordField RecField1 to true
The text of record fields, like that of foreground fields, resides in the foreground. Here the text is selected through a search, checked to see if it is already a hotword, and a hotword is created if one does not already exist. The newly minted hotword is named immediately after its creation. The hotword is an object of the recordfield, whether it is addressed by name or simply as objects of a specific recordfield. For example, if the hotword was named "Barney" and the recordfield was named "Rubble" the hotword could be found as any one of: objects of recordfield Rubble or hotword Barney of this page.or hotword Barney ofage,
The Hotword Book
backField1
This is background field BackField1. The text for this field is in the background, along with the field. Hotwords in this field are objects of this field of this background.
ckField1
partner
rival
cohort
rival
field id 5 of page id 6
partner
field id 6 of page id 6
cohort
button id 3 of page id 6
Remarks
fScripts
opartner
ocohort
orival
buttonUp
buttonUp
partner
cohort
rival
rival
field id 6 of page id 6
partner
button id 3 of page id 6
cohort
button id 4 of page id 6
to handle buttonUp
set syslockscreen to true
set selection to null
send author
send background
--put text of field fScripts into storage
--set text of field fScripts to null
search page for "BackField1"
if selection contains "hotword"
set name of selection to selectedText
break to system
end
send createHotword
get objects of Field BackField1 of this background
set name of last item of it to selectedText
send reader
--put storage into text of field fScripts
remarks
opartner
ocohort
orival
buttonUp
buttonUp
partner
cohort
rival
partner
button id 4 of page id 6
rival
field id 5 of page id 6
cohort
button id 3 of page id 6
This is the text
MainMenu
pMainMenu
buttonUp
buttonUp
pMainMenu
Main Menu
partner
button id 4 of page id 6
rival
field id 5 of page id 6
cohort
button id 3 of page id 6
This is the text
MainMenu
pMainMenu
buttonUp
buttonUp
pMainMenu
Main Menu
pGenRemarks
pForegroundFields
pRecordFields
B HA@
>2bdaR
pForegroundFields
bCreateHw
--Look
"ForeField1"
--Is
already a
? If so, quit early
--If you got
far,
--so
--Get
--See
"remarks" about
--The
must be
work OK
--Put
stuff
display
fScripts
buttonUp
buttonUp
ForeField1
hotword
GRcreateHotword
fScripts
ForeField1
Create Hotwords
bDestroyHW
forefield1
fScripts
storage
ForeField1
buttonUp
buttonUp
ForeField1
hotword
ForeField1
gremoveHotword
ForeField1
hotword
gremoveHotword
storage
fScripts
forefield1
Destroy Hotwords
Scripts
opartner
BbCreateHW
orival
ocohort
buttonUp
buttonUp
partner
partner
rival
cohort
bCreateHW
cohort
button id 30 of page id 2
rival
field id 31 of page id 2
partner
field id 5 of page id 2
Scripts
ForeField1
This is foreground field "ForeField1". The text of this field lives on the page(that is, the foreground). A hotword in this field is an object of the field. f field
fScripts
opartner
orival
buttonUp
buttonUp
partner
rival
rival
field id 31 of page id 2
partner
button id 3 of page id 2
to handle buttonUp
set syslockscreen to true
--Look for the search string
search page for "ForeField1"
--Is it already a hotword? If so, quit early
if selection contains "hotword"
break to system
end
--If you got this far, the text is not a hotword,
--so make one
send createHotword
--Get the handle to the hotword.
--See the "remarks" about this!
get objects of field ForeField1 of this page
set name of last item of it to selectedText
--The script of a foreground field must be
--activated for the hotword to work OK
set activated of field ForeField1 to true
--Put this stuff into the display field
set text of field fScripts to my script
Scripts
"fScripts"
BbCreateHW
B"remarks"
buttonUp
buttonUp
fScripts
remarks
remarks
fScripts
bCreateHW
Scripts
remarks
opartner
orival
ocohort
buttonUp
buttonUp
partner
rival
cohort
rival
field id 5 of page id 2
partner
field id 31 of page id 2
cohort
button id 3 of page id 2
Remarks
remarks
opartner
orival
buttonUp
buttonUp
partner
rival
partner
button id 30 of page id 2
rival
field id 5 of page id 2
The text of a foreground field lives on the page(foreground) along with the rest of the field. The hotwords are objects of the field immediately after they are created. Foreground fields are the easiest fields to handle, and should be the starting point for a beginner. As always, you must start the creation process by selecting the text you will turn into a hotword. In these scripts, this is done by executing a search for the text. The selectedText is then the target for the message "CreateHotword". It is always a good idea to set the name of the object immediately after its creation. In order to do so, one must first get a valid handle to the new hotword, often trickiest part of the process. In this case, the expression "objects of the field" will return a comma separated list of the objects of the field, all of which should be hotwords. Just the same, the script uses the contains operator to test that condition. The last hotword in the field will be the last object in the list. Knowing this is essential to naming the hotwords. After naming, the hotword is a hotword of the field, in addition to being an object of the page. A hotword named "Fred" in field "Flintstone" can be found as hotword Fred of field Flintstone. Since this is not the case for all types of fields, you need to be sure you know which type of field you are dealing with before you start.
MainMenu
pMainMenu
buttonUp
buttonUp
pMainMenu
Main Menu
reField1
pBackFields
bCreateHw
Create Hotwords
bDestroyHW
fScripts
storage
BackField1
buttonUp
buttonUp
author
background
hotword
gremoveHotword
reader
hotword
gremoveHotword
reader
BackField1
storage
fScripts
Destroy Hotwords
Scripts
opartner
BbCreateHW
orival
ocohort
buttonUp
buttonUp
partner
partner
rival
cohort
bCreateHW
cohort
button id 4 of page id 6
rival
field id 6 of page id 6
partner
field id 5 of page id 6
Scripts
remarks
opartner
orival
ocohort
buttonUp
buttonUp
partner
rival
cohort
rival
field id 5 of page id 6
partner
field id 6 of page id 6
cohort
button id 3 of page id 6
Remarks
fScripts
opartner
ocohort
orival
buttonUp
buttonUp
partner
cohort
rival
rival
field id 6 of page id 6
partner
button id 3 of page id 6
cohort
button id 4 of page id 6
--Hide the gory details
--You must be
,mode
there, so:
--Search
"BackField1"
--If
already a
, quit early
--If
far,
need
--Get a
. See
"Remarks"
--Name
critter
buttonUp
buttonUp
author
background
BackField1
hotword
reader
GRcreateHotword
reader
BackField1
remarks
opartner
ocohort
orival
buttonUp
buttonUp
partner
cohort
rival
partner
button id 4 of page id 6
rival
field id 5 of page id 6
cohort
button id 3 of page id 6
The field here is in the backg
MainMenu
pMainMenu
buttonUp
buttonUp
pMainMenu
Main Menu
to handle buttonUp
--Hide the gory details
set syslockscreen to true
--You must be in the background to select
--text in the background, and you must be
--in author mode to go there, so:
send author
send background
--Search for the text to select
search page for "BackField1"
--If there is already a hotword, quit early
if selection contains "hotword"
send reader
break to system
end
--If you got this far, you need to make a hotword
send createHotword
--Get a handle to the hotword. See the "Remarks" field!
get objects of Field BackField1 of this background
--Name the critter
set name of last item of it to selectedText
send reader
The field here is in the background. The text is in the background, and the hotwords can be found only as objects of the field of the background. It is important to remember that you need to be on the background when you select the text in a background field. If you do not do this, you are inviting trouble! Remember, always execute send author; send background before you create a hotword on the background!